<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="css/excite-bike/jquery-ui-1.8.22.custom.css"
	rel="stylesheet" type="text/css" />
<link href="css/table.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/jquery-ui-1.8.22.custom.min.js"></script>
<script src="js/jquery.cookie.js"></script>
<script src="js/widgets.js"></script>

<script type="text/javascript">

	function Click_Save() {
		$('#dialog-message').html('確定新增測試案例？');
		$("#dialog:ui-dialog").dialog("destroy");
		$('#dialog-message').dialog({
			resizable : false,
			height : 200,
			modal : true,
			buttons : {
				"確定" : function() {

					/**	先確認有輸入測試案例ID	**/
					var tcID = $.trim($('#tcID').val());
					var numKeyPoint = $.trim($('#numKeyPoint').val());
					if (tcID == "") { //如果沒輸入
						alert('測試案例ID為必輸欄位');
					} else if (numKeyPoint == "") {
						alert('驗證重點數為必輸欄位');
					} else {
						/**	先確認輸入的測試案例ID沒有重覆 **/
						/**	下面這三行，是將CKEDITOR內部的網頁語法，寫入要送出的三個變數 **/
						$('#tcKeyPoint')[0].value = CKEDITOR.instances.editor_tcKeyPoint.getData();
						$('#tcProcess')[0].value = CKEDITOR.instances.editor_tcProcess.getData();
						$('#tcResExp')[0].value = CKEDITOR.instances.editor_tcResExp.getData();
						$('#tcTestData')[0].value = CKEDITOR.instances.editor_tcTestData.getData();
						$('#tcNumKeyPoint')[0].value = $('#numKeyPoint').attr("value");
						
						if ($('#isAnalizeHierach').is(':checked')) {
							$('#submitIsAnalizeHierach')[0].value = "1";
						} else {
							$('#submitIsAnalizeHierach')[0].value = "0";
						}
						
						x = $('#q_form').serializeArray();
						$.ajax({
							type : 'post',
							url : 'DuplicateCheck',
							data : x,
							dataType : 'text',
							success : function(queryResult) {
								if (queryResult > 0) {
									alert('重覆了');
								} else {
									/** 沒有重覆  可以開始進行新增 **/
									$.ajax({
										type : 'post',
										url : 'InsertTCID',
										data : x,
										dataType : 'text',
										success : function(insRes) {
											alert(insRes);
										}
									});
								}
							},
							error : function() {
								alert('使用AJax失敗');
							}
						});
					}
					$(this).dialog("close");
				},
				"返回" : function() {
					$(this).dialog("close");
				}
			}
		});
	}

	$(document).ready(function() {
		$('button').button();
		$("#loginUser")[0].value = $.cookie("userID");
	});
</script>
<title>新增測試案例</title>
</head>
<body id="UI_CreateTC">

	************************
	<br/> &nbsp;&nbsp;&nbsp;~ 新建測試案例 ~
	<br/> ************************
	<br/>
	<p>
		<button id='but_tc_u' type="button" onClick="Click_Save()">儲存</button>
	<p />
	<br />
	<hr />

	<form id='q_form' method="post">
		<table id='createTCTableOne'>
			<tr>
				<th><div align="right">測試案例ID：</div></th>
				<td><input type="text" id='tcID' name='tcID' /><input
					type="checkbox" id="isAnalizeHierach" name="isAnalizeHierach" />解析階層<dfn id="cautionText">(以 _ 為分階符號)</dfn></td>
			</tr>
			<tr>
				<th><div align="right">案例名稱：</div></th>
				<td><input type="text" id='tcName' name='tcName' /></td>
			</tr>
			
			<tr>
				<th><div align="right">驗證重點數：</div></th>
				<td><input type="text" size="2" id='numKeyPoint' name='numKeyPoint' onkeyup="return ValidateNumber(this,value,false)" /></td>
			</tr>
		</table>
		<p />
		<table id='createTCTableTwo'>
			<thead id='createTCTableTwo_h'>
				<tr>
					<th>驗証重點</th>
					<th>測試資料</th>
					<th>測試流程</th>
					<th>預期結果</th>
				</tr>
			</thead>

			<tbody id='createTCTableTwo_b'>
				<tr>
					<td><textarea id="editor_tcKeyPoint" name="editor_tcKeyPoint"></textarea></td>
					<td><textarea id="editor_tcTestData" name="editor_tcTestData"></textarea></td>
					<td><textarea id="editor_tcProcess" name="editor_tcProcess"></textarea></td>
					<td><textarea id="editor_tcResExp" name="editor_tcResExp"></textarea></td>
				</tr>
			</tbody>
		</table>
		<input type="hidden" id="tcKeyPoint" name="tcKeyPoint" >
		<input type="hidden" id="tcProcess" name="tcProcess" >
		<input type="hidden" id="tcResExp" name="tcResExp" >
		<input type="hidden" id="tcTestData" name="tcTestData" >
		<input type="hidden" id="tcNumKeyPoint" name="tcNumKeyPoint" >
		<input type="hidden" id="loginUser" name="loginUser" >
		<input type="hidden" id="submitIsAnalizeHierach" name="submitIsAnalizeHierach" >
	</form>
	<script type="text/javascript">
	
		/* 這裡的位置要加上TMS唷!!! */
		/* CKEDITOR.replace("editor_tcProcess",{filebrowserUploadUrl : '/TMS/ckeditor/uploader?Type=File',filebrowserImageUploadUrl : '/TMS/ckeditor/uploader?Type=Image'});
		CKEDITOR.replace("editor_tcResExp",{filebrowserUploadUrl : '/TMS/ckeditor/uploader?Type=File',filebrowserImageUploadUrl : '/TMS/ckeditor/uploader?Type=Image'});
		CKEDITOR.replace("editor_tcTestData",{filebrowserUploadUrl : '/TMS/ckeditor/uploader?Type=File',filebrowserImageUploadUrl : '/TMS/ckeditor/uploader?Type=Image'});
		CKEDITOR.replace("editor_tcKeyPoint",{filebrowserUploadUrl : '/TMS/ckeditor/uploader?Type=File',filebrowserImageUploadUrl : '/TMS/ckeditor/uploader?Type=Image'}); */  
		CKEDITOR.replace("editor_tcProcess",{filebrowserUploadUrl : '/TMS/ckeditor/uploader',filebrowserImageUploadUrl : '/TMS/ckeditor/uploader'});
		CKEDITOR.replace("editor_tcResExp",{filebrowserUploadUrl : '/TMS/ckeditor/uploader',filebrowserImageUploadUrl : '/TMS/ckeditor/uploader'});
		CKEDITOR.replace("editor_tcTestData",{filebrowserUploadUrl : '/TMS/ckeditor/uploader',filebrowserImageUploadUrl : '/TMS/ckeditor/uploader'});
		CKEDITOR.replace("editor_tcKeyPoint",{filebrowserUploadUrl : '/TMS/ckeditor/uploader',filebrowserImageUploadUrl : '/TMS/ckeditor/uploader'});
		
	</script>
	<div id="dialog-message" title="確認"></div>

</body>
</html>